import { CallSprite } from "../selectPanel/CallSprite";
import { PlayerMiniInfo } from "../../../model/PlayerMiniInfo";
import { AvatarInfo } from "../../../resource/info/AvatarInfo";
import { AvatarType } from "../../../resource/info/AvatarType";
import { ImageInfo } from "../../../../../com/gengine/resource/info/ImageInfo";
import { MSecTimer } from "../../../../../com/gengine/core/frame/MSecTimer";
import { 01 } from "../../../../../0/01";
type int = number;
//class ChatHintIcon
    
    export  class ChatHintIcon extends CallSprite
    {
        constructor(arg1: PlayerMiniInfo)
        {
            super();
            this._playerMiniInfo = arg1;
            this._timer = new Object /* flash.utils.Timer */(500);
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.createView();
            this.addListeners();
            return;
        }

        /* internal  */createView(): void
        {
            var loc1;
            if (this._headBitmap == null) 
            {
                this._headBitmap = new Object /* flash.display.Bitmap */();
            }
            AvatarInfo.getAvatar(this._playerMiniInfo.camp, this._playerMiniInfo.sex, AvatarType.FRIEND, (arg1: ImageInfo): void
            {
                _headBitmap.bitmapData = arg1.bitmapData;
                _headBitmap.width = ChatHintIcon.iconWidth;
                _headBitmap.height = ChatHintIcon.iconWidth;
                addChild(_headBitmap);
                return;
            }, this._playerMiniInfo.avatarId)
            return;
        }

        /* internal  */addListeners(): void
        {
            this.addEventListener(flash.events.MouseEvent.CLICK, this.ClickHandler);
            this._timer.addEventListener(flash.events.TimerEvent.TIMER, this.TimerHandler);
            this._timer.start();
            return;
        }

        /* internal  */TimerHandler(arg1: Object /* flash.events.TimerEvent */): void
        {
            if (this._isFlicker) 
            {
                this._headBitmap.alpha = this._headBitmap.alpha != 1 ? 1 : 01;
            }
            return;
        }

        /* internal  */ClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.isFlicker = false;
            callAll(null);
            return;
        }

        /* internal  */flickerHandler(arg1: MSecTimer): void
        {
            this._headBitmap.visible = !this._headBitmap.visible;
            return;
        }

        public get isFlicker(): Boolean
        {
            return this._isFlicker;
        }

        public set isFlicker(arg1: Boolean)
        {
            this._isFlicker = arg1;
            if (!this._isFlicker) 
            {
                this._headBitmap.alpha = 1;
            }
            return;
        }

        public get chatPlayerName(): string
        {
            return this._playerMiniInfo.playerName;
        }

        public refresh(arg1: PlayerMiniInfo): void
        {
            this._playerMiniInfo = arg1;
            this.createView();
            return;
        }

        public static /* const */iconWidth: int=36;

        /* internal */ /* var */_playerMiniInfo: PlayerMiniInfo;

        /* internal */ /* var */_isFlicker: Boolean=false;

        /* internal */ /* var */_headBitmap: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;
    }
